

package org.springframework.security.core.userdetails;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.io.Serializable;
import java.util.Collection;

/**
 * 1.SS定义了UserDetails接口来规范化开发者自定义的用户对象，这样方便一些旧系统、用户表已经固定的系统集成到SS认证体系中。
 * @see UserDetailsService
 * @see UserCache
 *
 * @author Ben Alex
 * @author  sam
 */
public interface UserDetails extends Serializable {
	// ~ Methods
	// ========================================================================================================

	/**
	 * 返回当前账户所具备的权限
	 *
	 * @return the authorities, sorted by natural key (never <code>null</code>)
	 */
	Collection<? extends GrantedAuthority> getAuthorities();

	/**
	 * 返回当前账户的密码
	 *
	 * @return the password
	 */
	String getPassword();

	/**
	 * 返回当前账户的用户名
	 *
	 * @return the username (never <code>null</code>)
	 */
	String getUsername();

	/**
	 * 返回当前账户是否未过期
	 *
	 * @return <code>true</code> if the user's account is valid (ie non-expired),
	 * <code>false</code> if no longer valid (ie expired)
	 */
	boolean isAccountNonExpired();

	/**
	 * 返回当前账户是否未锁定
	 *
	 * @return <code>true</code> if the user is not locked, <code>false</code> otherwise
	 */
	boolean isAccountNonLocked();

	/**
	 * 返回当前账户凭证(如密码)是否未过期
	 *
	 * @return <code>true</code> if the user's credentials are valid (ie non-expired),
	 * <code>false</code> if no longer valid (ie expired)
	 */
	boolean isCredentialsNonExpired();

	/**
	 *返回当前账户是否可用
	 *
	 * @return <code>true</code> if the user is enabled, <code>false</code> otherwise
	 */
	boolean isEnabled();
}
